// SessionProductoClient.java
// mini Client for accessing bean SessionProducto

package com.ipharma.client;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import com.ipharma.beans.SessionProducto;
import com.ipharma.beans.SessionProductoHome;

/**
 * 
 */
public class SessionProductoClient {

	static Context ctx = null;

	

	public static void main(String[] arg) {

		// Get InitialContext
		try {
			ctx = getInitialContext();
		} catch (NamingException e) {
			e.printStackTrace();
			System.exit(2);
		}
		// Lookup bean home
		String bName = "SessionProductoHome";
		try {
			SessionProductoHome home;
			home = (SessionProductoHome) PortableRemoteObject.narrow(ctx
					.lookup(bName), SessionProductoHome.class);
			SessionProducto bean = home.create();
			System.out.println(bean.findAll());

		} catch (Exception e) {
			e.printStackTrace();
			System.exit(2);
		}

		// ...
	}

	/**
	 * Using a Properties object will work on JDK 1.1.x and Java2 clients
	 */
	static private Context getInitialContext() throws NamingException {
		String url = "rmi://localhost:1099";

		try {
			// Get an InitialContext
			Properties h = new Properties();
			h.put(Context.INITIAL_CONTEXT_FACTORY,
				"org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
			h.put(Context.PROVIDER_URL, url);
			return new InitialContext(h);
		} catch (NamingException ne) {
			ne.printStackTrace();
			throw ne;
		}
	}

}
